package com.sjlh.centurylianhua.mapper;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sjlh.centurylianhua.entity.PurchaseLog;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List;

public interface PurchaseLogMapper extends BaseMapper<PurchaseLog> {
    /**
     *查询内容：
     * purchase_log表的所有，
     * depot 表的 name 起别名为 depotName 以便自动赋值 PurchaseLog 类中的 depotName 属性
     * supplier 表的 name 起别名为 supplierName 以便自动赋值 PurchaseLog 类中的 supplierName 属性
     * ${ew.customSqlSegment} 传递wrapper条件的固定写法
     * */
    @Select("select purchase_log.*,user.userName, depot.name as depotName,supplier.name as supplierName  from purchase_log, depot,supplier,user"            +" ${ew.customSqlSegment} ")
    List<PurchaseLog> getInfo(@Param("ew") QueryWrapper<PurchaseLog> wrapper);

    /**
     *查询内容：
     * purchase_log表的所有，
     * depot 表的 name 起别名为 depotName 以便自动赋值 PurchaseLog 类中的 depotName 属性
     * supplier 表的 name 起别名为 supplierName 以便自动赋值 PurchaseLog 类中的 supplierName 属性;
     * page 封装分页对象
     * ${ew.customSqlSegment} 传递wrapper条件的固定写法
     * */
    @Select("select purchase_log.*,user.userName, depot.name as depotName,supplier.name as supplierName  from purchase_log, depot,supplier,user"
            +" ${ew.customSqlSegment} ")
    Page<PurchaseLog> getInfoPage(Page<PurchaseLog> page, @Param("ew") QueryWrapper<PurchaseLog> wrapper);
    //采购统计数据，显示人员名称
    @Select("select sum(pu.total) standby3,user.userName userName from purchase_log pu,user"
            +" ${ew.customSqlSegment} group by pu.userId")
    List<PurchaseLog> purCount(@Param("ew") QueryWrapper<PurchaseLog> wrapper);

}
